<template>
  <div>
    <b-overlay>
      <b-table :fields="fields" :items="items" table-class="text-center">
        <template #head(checkbox)>
          <b-form-checkbox v-model="allSelected"></b-form-checkbox>
        </template>
        <template #cell(checkbox)="{ item }">
          <b-form-checkbox-group v-model="selectedData">
            <b-form-checkbox :value="item.id" class="m-0"></b-form-checkbox>
          </b-form-checkbox-group>
        </template>
        <template #cell(op)='{item}'>
          <b-button-group>
            <b-button size="sm" variant="warning">编辑</b-button>
            <b-button size="sm" variant="success">详细信息</b-button>
            <b-button size="sm" variant="info" @click="$router.push({path: `/commodity/page/${item.cid}`})">页面管理</b-button>
          </b-button-group>
        </template>
      </b-table>
    </b-overlay>
  </div>
</template>

<script>
export default {
  data() {
    return {
      selectedData: [],
      allSelected: false,
      items: [],
      fields: [
        { key: "checkbox", label: "" },
        { key: "index", label: "索引" },
        { key: "name", label: "名称" },
        { key: "tname", label: "类别" },
        { key: "comm", label: "在卖商家数" },
        { key: "createDate", label: "创建日期" },
        { key: "op", label: "操作" },
      ],
    };
  },
  methods: {
    onTab(tab) {
      var type = tab == 0 ? "comm" : "topic";
      if (this.$route.query.type === type) return;
      this.$router.push({
        path: "comm",
        query: { type: type },
      });
    },
    load() {
      this.$haier.get("admin/commodity", { topic: this.tid }).then((res) => {
        this.items = res.data;
      });
    },
  },
  created() {
    this.load();
  },
  props: {
    tid: String,
  },
};
</script>


<style>
</style>